home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / System 7.0 Samples / Kibitz⁄THINK C / Sound.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-21  |  2.3 KB  |  122 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** Program:          Kibitz
  5. ** File:             sound.c
  6. ** Originally from:  SoundCdev by Jeremy Bornstein
  7. ** Modified by:      Eric Soldan
  8. **
  9. ** Copyright © 1990-1991 Apple Computer, Inc.
  10. ** All rights reserved.
  11. */
  12.  
  13.  
  14.  
  15. /*****************************************************************************/
  16.  
  17.  
  18.  
  19. #include "Kibitz.h"                /* Get the Kibitz includes/typedefs, etc.    */
  20. #include "KibitzCommon.h"        /* Get the stuff in common with rez.        */
  21. #include "Kibitz.protos"        /* Get the prototypes for Kibitz.            */
  22.  
  23. #ifndef __ERRORS__
  24. #include <Errors.h>
  25. #endif
  26.  
  27. #ifndef __FILES__
  28. #include <Files.h>
  29. #endif
  30.  
  31. #ifndef __SOUND__
  32. #include <Sound.h>
  33. #endif
  34.  
  35. #ifndef __SOUNDINPUT__
  36. #include <SoundInput.h>
  37. #endif
  38.  
  39. #ifndef __UTILITIES__
  40. #include "Utilities.h"
  41. #endif
  42.  
  43.  
  44.  
  45. /*****************************************************************************/
  46. /*****************************************************************************/
  47.  
  48.  
  49.  
  50. #pragma segment Main
  51. OSErr    RecordSound(FileRecHndl frHndl)
  52. {
  53.     Handle    newSnd, oldSnd;
  54.     OSErr    err;
  55.     Point    corner = {50, 50};
  56.  
  57.     if (!(newSnd = NewHandle(31 * 1024)))
  58.         return(memFullErr);
  59.  
  60.     err = SndRecord(nil, corner, siBetterQuality, &newSnd);
  61.  
  62.     if (!err) {
  63.         if (oldSnd = (*frHndl)->doc.sound) DisposHandle(oldSnd);
  64.         (*frHndl)->doc.sound = newSnd;
  65.     }
  66.     else DisposHandle(newSnd);
  67.  
  68.     return(err);
  69. }
  70.  
  71.  
  72.  
  73. /*****************************************************************************/
  74.  
  75.  
  76.  
  77. /* SoundInputAvaliable
  78. **
  79. ** Sound input is avaliable if there's a device registered…
  80. */
  81.  
  82. #pragma segment Main
  83. Boolean SoundInputAvaliable(void)
  84. {
  85.     Boolean        siPresent;
  86.     Handle        devIconHandle;
  87.     Str255        devName;
  88.     NumVersion    vers;
  89.     long        result;
  90.     OSErr        err;
  91.     
  92.     siPresent = false;
  93.     
  94.     if (gSystemVersion >= 0x0700) {
  95.  
  96. #ifdef THINK_C
  97. /*        
  98. 2/21/91 pvh - Below call not available with THINK C.  It can't support over 32 bits on returned 
  99. Pascal type functions.  We should be using Gestalt() for this in any case, so we will.
  100. */
  101.         err = Gestalt(gestaltSoundAttr, &result);
  102.         if(BitTst(&result, 31-gestaltHasSoundInputDevice)) 
  103.             vers.majorRev = 1;
  104.         else
  105.             vers.majorRev = 0;
  106. #else
  107.         vers = SndSoundManagerVersion();
  108. #endif
  109.         if (vers.majorRev > 0) {
  110.             if (SPBGetIndexedDevice(1, devName, &devIconHandle) == noErr) {
  111.                 DisposHandle(devIconHandle);
  112.                 siPresent = true;
  113.             }
  114.         }
  115.     }
  116.  
  117.     return(siPresent);
  118. }
  119.  
  120.  
  121.  
  122.